import inspect 
import re
import os 
import sys
import pandas as pd
import numpy as np 

test_path = '/mnt/d/个人目标/my_git_hub/my_life/core'

os.chdir(test_path)

save_path = test_path+'/test.csv'


hour_list = list(range(24))
minute_list = []

for i in list(range(60)):
    if i < 10:
        minute_list.append('0'+str(i))
    else:
        minute_list.append(i)

hour_minute_list = []

for h in hour_list:
    for m in minute_list:
        hour_minute = "{}:{}".format(h, m)
        hour_minute_list.append(hour_minute)



"""
#! 如果文件已存在则不再创建，也不覆盖
"""
if os.path.isfile(save_path):
    pass
else:
    df = pd.DataFrame(index=hour_minute_list)
    # df.index = hour_minute_list
    df.rename(index='time')
    df.to_csv(save_path, encoding='utf_8_sig')


test = pd.read_csv('test.csv', encoding='utf_8_sig',index_col=0)
test.head()


test['6月30日'] = np.nan

test.loc['0:0':'0:4','6月30日'] = 1
test.to_csv(save_path, encoding='utf_8_sig')

test2 = pd.read_csv('test.csv', encoding='utf_8_sig', index_col=0)

test2.head()

test2.loc['0:0':'0:4','6月30日'] = 2

test2.to_csv(save_path, encoding='utf_8_sig')

'6月31日' in test2.columns


test3 = pd.read_csv('test.csv', encoding='utf_8_sig', index_col=0)

hour_list = list(range(24))
test_list = ('0'+str(i) if i<10 else i for i in list(range(60)))


test_time_list2 = []
for h in hour_list:
    for m in test_list:
        hour_minute = "{}:{}".format(h, m)
        test_time_list2.append(hour_minute)

a = "18:00"
b = "9：29"

c = re.findall(r'\d{1,2}', a)

d = re.findall(r'\d{1,2}', b)

r = ':'.join(d)

r